package com.cxf.windex.entity;

import com.vdurmont.emoji.EmojiParser;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@ApiModel(description = "用户信息")
@Table(name = "js_user")
@Builder(toBuilder = true)
@AllArgsConstructor(access = AccessLevel.PACKAGE)
@NoArgsConstructor
@Getter
@Setter
public class JsUser {

    /**
     * ID
     */
    @Id
    private String id;

    /**
     * 用户名
     */
    @ApiModelProperty(value = "用户名", required = true)
    private String username;

    /**
     * 密码
     */
    private String password;

    /**
     * 姓名
     */
    @ApiModelProperty(value = "昵称", required = true)
    private String name;

    /**
     * 生日
     */
    private String birthday;

    /**
     * 手机
     */
    @ApiModelProperty(value = "手机", required = true)
    private String mobile;

    /**
     * 邮件
     */
    private String email;

    /**
     * 性别
     */
    @ApiModelProperty(value = "性别")
    private String sex;

    /**
     * 类型
     */
    private String type;

    /**
     * 状态
     */
    private String status;

    /**
     * 描述
     */
    private String description;

    /**
     * 创建时间
     */
    @Column(name = "crt_time")
    private Date crtTime;

    /**
     * 创建用户id
     */
    @Column(name = "crt_user")
    private String crtUser;

    /**
     * 创建用户姓名
     */
    @Column(name = "crt_name")
    private String crtName;

    /**
     * 创建用户IP
     */
    @Column(name = "crt_host")
    private String crtHost;

    /**
     * 更新时间
     */
    @Column(name = "upd_time")
    private Date updTime;

    /**
     * 更新用户id
     */
    @Column(name = "upd_user")
    private String updUser;

    /**
     * 更新用户姓名
     */
    @Column(name = "upd_name")
    private String updName;

    /**
     * 更新用户IP
     */
    @Column(name = "upd_host")
    private String updHost;

    @Column(name = "del_flg")
    private Integer delFlg;

    /**
     * 微信OPenId
     */
    @ApiModelProperty(value = "openid", required = true)
    private String openid;

    @Transient
    private String  inviter;



    /**
     * 设置姓名
     *
     * @param name 姓名
     */
    public void setName(String name) {

        name = EmojiParser.parseToAliases(name);
        this.name = EmojiParser.parseToUnicode(name);

    }


}
